//
//  DataModel.h
//  TuYouAPP
//
//  Created by L on 14-2-21.
//
//

#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
@class AVObject;
@class AVGeoPoint;

typedef enum _gotoPage
{
    
    E_NotGoto           = 0,//不需要跳转
    E_ReBackMe          = 1,//回复我
    E_ReBackMyStatus    = 2,//回复了我的动态
    E_StatusDetail      = 3,//动态详情
    
}GotoPage;

typedef enum _contentStyle
{
    E_UnKnow = 0,//其他
    E_View = 1,//风景
    E_Bed  = 2,//住宿
    E_Traffice = 3,//交通
    E_Food = 4,//美食
    E_Play = 5,//娱乐
    E_Shop = 6,//购物
    E_Help = 7,//求助
    E_Finder = 8,//约伴
}contentStyle;

typedef enum _userflag
{
    E_flag_have_reback  = (1 << 0),//有回复的提示
    E_flag_have_reply   = (1 << 1),//有评论我的提示
    
}UserFlag;


@interface DataModel : NSObject

@end

@interface Citys : NSObject

@property (copy, nonatomic) NSString *country;
@property (copy, nonatomic) NSString *state;
@property (copy, nonatomic) NSString *city;
@property (copy, nonatomic) NSString *district;
@property (copy, nonatomic) NSString *street;
@property (nonatomic) double latitude;
@property (nonatomic) double longitude;

@end


@interface TYVersion : NSObject

+(void)getNewVersion:(void(^)(BOOL have,NSString *url,NSString *versionNum,NSString *Desc,NSString *error))callback;
@end

@class TYRoad;
@class TYNode;
@class TYLine;

@interface TYUser : NSObject
@property (nonatomic,strong)NSString *mnowUserpointAddr;
@property (nonatomic,strong) NSString *mObjId;
@property(nonatomic,strong) NSString*   mUserPointAddr;//昵称
@property(nonatomic,strong) NSString*   mUserDisplayName;//昵称
@property(nonatomic,strong) NSString*   mHeadImgURL;
@property(nonatomic,strong) NSString*   mAge;
@property(nonatomic,strong) NSString*   mDuijiang;
@property(nonatomic,strong) NSString*   mUserSign;
@property(nonatomic,assign) int         mSex;//0未知,1女,2男
@property(nonatomic,assign) BOOL        type;//是否是我们自己的用户,否则是微博用户
@property(nonatomic,assign) BOOL        mbchanged;


@property(nonatomic,strong) TYNode*     mNowIAtNode;
@property(nonatomic,strong) TYRoad*     mNowIAtRoad;
@property(nonatomic,strong) TYLine*     mNowIAtLine;

+(BOOL)isNeedLogin;

+(TYUser *)currentUser;
+(void)updateUser;
-(void)modifyUserinfoSex:(NSString*)sex headImage:(UIImage *)headrImage name:(NSString *)name addr:(NSString *)addr sign:(NSString *)sigin age:(int)age duijiang:(NSString *)duijiang callback:(void(^)(NSString *eror))callback;

//获取我的发布
-(void)getMyPublish:(int)page  AnyCall:(void(^)(NSArray* array,NSString *eror))callback;

//获取我的发布数量
-(void)getMyPublishCount:(void(^)(int c ))callback;
-(void)getReplyMeCount:(void(^)(int count ,NSString *error))callback;
-(void)getReplyMepage:(int)apge call:(void(^)(NSArray * arr,NSString *error))callback;
//获取我参与过的回复
-(void)getMyCommentNewState:(int)page AnyCall:(void(^)(NSArray* array,NSString *eror))callback;

-(void)getMyCommentCount:(void(^)(int c))callback;
//type,1==>我们的用户,0==>微博用户,.
-(id)initWithAV:(AVObject*)av bouruser:(BOOL)bouruser;

//获取的标志
-(void)getMyFlag:(void(^)(NSInteger flag ,NSString *eror))callback;

-(void)clearAllFlags;

-(void)clearFlag:(UserFlag)f;

//获取所有未处理的我的页面,
-(void)getAllNotDealCount:(void(^)(NSInteger count ,NSString *eror))callback;

//返回我在哪个路段上面,howLast表示当前,howLast =1 表示前一段,howLast = 2,表示前2段,...
-(TYRoad*)whereIat:(int)howLast;


@end


@class TYUserState;


@interface TYCommment : NSObject

@property(nonatomic,strong) NSString*   mText;
@property(nonatomic,strong) NSString*   mTime;//比如:7分钟前
@property(nonatomic,strong) NSString*   mUserName;//评论者名字
@property(nonatomic,strong) NSString*   mTagUserName;//如果是指定回复的某个人.这就是那个人的名字,否则是空
@property (nonatomic,strong)    NSDate*         mTimeC;//时间戳
@property (nonatomic,strong) TYUserState*   mWhichIComent;
-(id)initWithAV:(AVObject*)av;
-(id)initWithAV:(AVObject *)av username:(NSString*)username;
//回复这个评论
-(void)reBackThis:(NSString*)txt callback:(void(^)(NSString* err ,TYCommment *nowComment))callback;


@end

//用户动态信息
@interface TYUserState : NSObject

@property (nonatomic,strong)    TYUser*         mTaguser;//发布动态的用户
@property (nonatomic,strong) NSString *objId;
@property (nonatomic,strong)    NSString*       mContext;//内容
@property (nonatomic,strong)    NSArray*        mImgArr;//图片URL数组
@property (nonatomic,assign)    contentStyle    mStyle;
@property (nonatomic,strong)    NSString*       mRelInfo;//关联地点或者路段.比如:九寨沟,G318雅安-理塘段
@property (nonatomic,strong)    NSString*       mPointInfo;//地点位置信息,比如:重庆,重庆沙坪坝
@property (nonatomic,strong)    NSString*       mTimeText;//比如:8分钟前
@property (nonatomic,strong)    NSString*       mPBetweenInfo;//比如:西北28km
@property (nonatomic,assign)    int             mReBackCount;//回复数量

@property (nonatomic,strong)    NSDate*         mTimeC;//时间戳

//这个在我的页面需要
@property (nonatomic,strong)    TYCommment*     mNewestComment;//最新的一条回复

//发布一条动态,
//pusblishAtHere 发布的坐标位置,
//pointinfo 发布的地理位置比如:重庆,重庆沙坪坝
//txt 发布的文字
//imgArr 图片URL数组,比如:[@"http://wwww.jpg",@"http://www.111.jpg"];

+(void)getOneStatus:(NSString*)objid callback:(void(^)(TYUserState* one, NSString* err))callback;
+(void)publishState:(CLLocationCoordinate2D)pusblishAtHere pointinfo:(NSString*)pointinfo txt:(NSString*)txt imgArr:(NSArray*)imgArr callback:(void(^)(NSString* err,NSString*objid))callback;



-(id)initWithAV:(AVObject*)av;

//获取评论
-(void)getComment:(int)page callback:(void(^)(NSArray* arr, NSString* err))callback;

//获取评论
-(void)getCommentByTime:(NSDate*)theTime bback:(BOOL)bback  callback:(void(^)(NSArray* arr, NSString* err))callback;

//回复这个动态
-(void)commentThis:(NSString*)txt tagUser:(NSString *)objid coordnate:(CLLocationCoordinate2D)itpoint callback:(void(^)( NSString* err,TYCommment *comment))callback;;

//增加回复数量,异步,
-(void)addCommentCount;

@end

@class TYNode;
@class TYRoad;
@interface TYLine : NSObject
//all ==> TYLine
+(void)getAllLines:( void(^)(NSArray* all,NSString* err) )callback;

//根据节点来获取线路,这个不能简单的这样获取,比如,关联到了成都的一个小节点,但是,
//这个小节点又没有配置到线路里面,这样,就不能被找到,
+(TYLine*)getLineWithNode:(TYNode*)node;

//根据路段来获取线路
+(TYLine*)getLineWithRoad:(TYRoad *)road;

-(id)initWithAV:(AVObject*)av;

-(NSString*)fetchAllRoad;

//获取置顶的动态
-(void)getTopState:( void(^)( TYUserState* thetop ,NSString* err) )callback;

//
-(TYUserState *)getFirstTishi;


//获取最新动态 theTime基于的时间 bback YES表示向后加载,NO,表示向前加载
-(void)getNewestStateOfTheLineByTime:(NSDate*)theTime bback:(BOOL)bback callback:( void(^)(NSArray* all,NSString* err) )callback;

//获取精华
-(void)getBestStatesOfTheLineByTime:(int)page bback:(BOOL)bback callback:( void(^)(NSArray* all,NSString* err) )callback;
//获取提示
-(void)getTishiStatesOfTheLineByTime:(int)page bback:(BOOL)bback callback:( void(^)(NSArray* all,NSString* err) )callback;

@property(nonatomic,strong) NSString*   mLineName;//
@property(nonatomic,strong) NSString*   mLineDesc;//净化之旅
@property(nonatomic,strong) NSString*   mBackImgURL;
@property(nonatomic,strong) NSString*   mTopTipText;//DD:前方路塌方
@property(nonatomic,strong) TYUserState*   mTopUserStatus;;//DD:前方路塌方
@property(nonatomic,strong) NSString*   mOjid;
@property(nonatomic,assign) int         mSameWayCount;  //同路人数
@property(nonatomic,strong) NSArray*    mAllSubRoadOjid;    //所有子路段
@property(nonatomic,strong) NSArray*    mAllNodeOjid;//所有节点

@property(nonatomic,strong) NSArray*    mAllRoadObj;//获取所有路段对象
@property(nonatomic,strong) NSArray*    mAllNodeObj;//获取所有节点对象

@property(nonatomic,strong) NSArray*    mAllNodeIds;

@end

//节点
@interface TYNode : NSObject

-(id)initWithAV:(AVObject*)av;

@property(nonatomic,strong)NSString*    mOjid;
@property(nonatomic,strong)NSString*    mName;//比如:九寨沟
@property(nonatomic,assign)int          mcityid;
@property(nonatomic,assign)int          mNodeId;
@property(nonatomic,strong)AVObject*    mTheAV;

//关联这个点到附近最近的节点,可能耗时
+(TYNode*)getNearNode:(CLLocationCoordinate2D)point;

@end

//路段
@interface TYRoad : NSObject
-(id)initWithAV:(AVObject*)av;

@property(nonatomic,strong)NSString*    mOjid;
@property(nonatomic,strong)NSString*    mName;//比如:雅安-理塘
@property(nonatomic,strong)NSString*    mSpeed;//80KM/h
@property(nonatomic,strong)NSString*    mRoadLevel;//国道
@property(nonatomic,strong)NSString*    mRoadNO;//G318
@property(nonatomic,strong)NSString*    mDesc;//描述
@property(nonatomic,strong)NSString*    mDist;//长度 50KM

@property(nonatomic,strong)NSString*    mstartNodeOjid;
@property(nonatomic,strong)NSString*    mendNodeOjid;
@property(nonatomic,strong)TYNode*      mStartNode;
@property(nonatomic,strong)TYNode*      mEndNode;

//关联到路段
+(TYRoad*)getNearRoad:(CLLocationCoordinate2D)point;

@end

@interface testData : NSObject
@property (nonatomic,strong) NSString *time;
@property  (nonatomic,strong) NSString *myReply;
@property (nonatomic,strong) UIImage *headImage;
@property (nonatomic,strong) NSString *contentStr;
@end


@interface TYAd : NSObject

//获取广告
+(void)getTYAD:( void(^)(TYAd* oneAD,NSString* err) )callback;

@property(nonatomic,strong) NSString*   mimgURL;

-(id)initWithAV:(AVObject*)av;

@end


@interface TYUtil : NSObject

//处理起泡
+(void)dealBadge;

//更新用户信息
+(void)updateUserPoint;

//发送推送
+(void)sendItPush:(GotoPage)go txt:(NSString*)txt userOjid:(NSString*)userOjid;


+(void)markUserStatus:(NSString*)userOjid  flag:(NSInteger)flag;

@end


#import <AMapSearchKit/AMapSearchAPI.h>
@interface GInfo : NSObject<AMapSearchDelegate>



+(GInfo*)shareClient;

@property(nonatomic,assign) BOOL                    mIsVaild;//下面那个坐标是否有效
@property(nonatomic,assign) CLLocationCoordinate2D  mNowUserPoint;
@property(nonatomic,strong) NSArray*                mAllLine;//所有线路
@property(nonatomic,assign) int                     mRelNodeDistConfig;//节点关联距离设置,
@property(nonatomic,assign) int                     mRoadNearDistConfig;//在线路附近多远算合格
@property(nonatomic,assign)  BOOL isAVOSCloud;
@property (nonatomic,strong) AMapSearchAPI *search;

@property (nonatomic,assign) GotoPage       mgoto;
@property (nonatomic,strong) NSString*      mojid;

-(void)updateUserAddr:(AVGeoPoint*) coordinate;

@end


